<?php

namespace app\api\controller\v1;

use app\api\validate\IDIsInt;
use app\lib\exception\BannerMissException;
use think\Controller;
use Exception;

class Banner extends Controller
{
    //
    public function getBanner($id)
    {
        /*$data = [
            'id' => $id
        ];
        $validate = new IDIsInt();
        $result = $validate->batch()->check($data);
        if ($result) {
        } else {
        }*/

        // 创建验证器
        (new IDIsInt())->goCheck();
        $banner = \app\api\model\Banner::getBannerBySort($id);

        if (!$banner) {
            throw new BannerMissException();
//            throw new Exception('服务器出现错误了');
        }

        return $banner;
    }
}
